﻿using UnityEngine;
using UnityEngine.UI;

public class SelectCampPanel : BaseComponent
{
    private Button exitBtn;
    private Button redCampBtn;
    private Button blackCampBtn;
    private Button retractBtn;
    private GameObject stashPanelGo;
    private GameObject functionPanelGo;
    private GameObject calculatingGo;
    public override void Binding()
    {
        SelectCampPanelModel cm = (SelectCampPanelModel)GetComponentModel();
        exitBtn = transform.Find("ExitBtn").GetComponent<Button>();
        redCampBtn = transform.Find("StashPanel/RedCampBtn").GetComponent<Button>();
        blackCampBtn = transform.Find("StashPanel/BlackCampBtn").GetComponent<Button>();
        retractBtn = transform.Find("FunctionPanel/RetractBtn").GetComponent<Button>();
        stashPanelGo = transform.Find("StashPanel").gameObject;
        functionPanelGo = transform.Find("FunctionPanel").gameObject;
        calculatingGo = transform.Find("calculating").gameObject;
        exitBtn.onClick.AddListener(cm.OnClickExit);
        redCampBtn.onClick.AddListener(cm.OnClickRedCampBtn);
        blackCampBtn.onClick.AddListener(cm.OnClickBlackCampBtn);
        retractBtn.onClick.AddListener(cm.OnClickRetract);
        BindData(cm.showStashPanel, (bool value) =>
        {
            stashPanelGo.SetActive(value);
        });
        BindData(cm.showFunction, (bool value) =>
        {
            functionPanelGo.SetActive(value);
        });
        BindData(cm.isCalculatingDM, (bool value) =>
        {
            calculatingGo.SetActive(value);
        });
    }

    public override void UnBinding()
    {

    }
}